package com.devin.filter;

import java.util.Iterator;
import java.util.List;
import java.util.Map;

/**
 * @author ascetic
 * @version 1.0
 * @ClassName RemoveDataThread
 * @Description TODO
 * @date 2020-07-14 13:06
 */
public class RemoveDataThread implements Runnable {

    private Map<String, List<MethodInfo>> methodTimes;

    public RemoveDataThread(Map<String, List<MethodInfo>> methodTimes) {
        this.methodTimes = methodTimes;
    }

    @Override
    public void run() {
        System.out.println("---删除过期数据---");
        for(Map.Entry<String,List<MethodInfo>> methodInfos:methodTimes.entrySet()){
           List<MethodInfo> methodList = methodInfos.getValue();
           Iterator<MethodInfo> iterator = methodList.iterator();
           Long removeCon = System.currentTimeMillis() - 6000;
           while (iterator.hasNext()){
               MethodInfo methodInfo = iterator.next();
               if(methodInfo.getEndTime() < removeCon)
                   iterator.remove();
           }
        }
    }
}